<?php


class WacDispatchOrderTable extends WacCommonTable
{
    
    public static function getInstance()
    {
        return Doctrine_Core::getTable('WacDispatchOrder');
    }

    /*
     * return a custome list
     */
    public function getCustomList($arrParams, $page=1, $maxPerPage=20, $isArr=true)
    {
       $objQuery = $this->createQuery('t1')
                ->select('t1.*')
                ->from("WacDispatchOrder t1")
                ->leftJoin("t1.WacMaker wm")
                ->leftJoin("t1.WacAuditor wa")
                ->leftJoin("t1.WacSupplier ws")
                ->leftJoin("t1.WacTarget wt")
                ->leftJoin("t1.WacProductionOrder wpo");

        if(is_array($arrParams) && count($arrParams)>0)
        {
            QueryHelper::processOption($objQuery, $arrParams);  // dont set "offset" and "limit" option in it
        }

        $this->_pager = new Doctrine_Pager($objQuery, $page, $maxPerPage);
        if($isArr)
        {
            $items = $this->_pager->execute(array(), Doctrine::HYDRATE_ARRAY);
        }
        else
        {
            $items = $this->_pager->execute();
        }
        $objQuery->free();
        return $items;
    }
}